/*
 * PlainDocument.cpp
 *
 *  Created on: Sep 13, 2012
 *      Author: sbellus
 */

#include "PlainDocument.h"
#include "PlainParagraph.h"

#include <PrinterLibrary/Printer.h>

PlainDocument::PlainDocument()
{
}

PlainDocument::~PlainDocument()
{
   std::vector<Printable*>::iterator printable = printables.begin();

   while (printable != printables.end())
   {
      delete (*printable);
      printable++;
   }
}

Paragraph& PlainDocument::AddParagraph(void)
{
   Paragraph* p = new PlainParagraph();
   printables.push_back(p);
   return *p;
}

void PlainDocument::PrintOn(Printer& printer)
{
   std::vector<Printable*>::iterator printable = printables.begin();

   while (printable != printables.end())
   {
      (*printable)->PrintOn(printer);
      printable++;
   }
}
